<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/base.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/info-mgt.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/WdatePicker.css" />
<link rel="stylesheet" href="__TMPL__Public/assets/layui/css/layui.css">
<link rel="stylesheet" href="__TMPL__Public/assets/book_static/css/pager.css">
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/layui/layui.js"></script>
<title>图书库存管理系统</title>
</head>

<body onload="javascript:window.print();" style="width:100%;text-align:center;margin: auto;">
<div class="title"><h2>图书出库单打印</h2></div>


<div class="table-box">
	<table>
    	<thead>
        	<tr>
                <th class="name" style="width:5%">ISBN</th>
                <th class="node" style="width:68%">书名</th>
				<th class="process" style="width:5%">位置</th>
                <th class="name" style="width:17%">数量<span>(本)</span></th>
                <th class="name" style="width:5%">价格</th>
            </tr>
        </thead>
        <tbody>
			<foreach name="data.list" item="vo" key="k">
        	<tr class="{$vo.id}" style="border: 1px solid #c1d3de">
                <td class="name isbn" vi="{$vo.bookname}">{$vo.isbn}</td>
                <td class="node bookname" style="width:390px">
				<if condition="$vo.bookname neq ''">
				{$vo.bookname}
				<else/>
				--
				</if>
				</td>
                <td class="process">
				<?php
				if($vo['location']=="缺货"){
					echo "<font color=red>缺货</font>";
				}else{
					echo $vo['location'];
				}
				?>
				</td>
                <td class="name">{$vo.booknum}</td>
                <td class="name">{$vo.price}</td>
            </tr>
			</foreach>
        </tbody>
    </table>
</div>

<div class="pxofy">合计{$data.count}本书</div>
<div class="page-control ue-clear"></div>


</body>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.page.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/common.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/WdatePicker.js"></script>
<script type="text/javascript" src="__TMPL__Public/assets/book_static/js/jquery.pagination.js"></script>

<script type="text/javascript">
$(".select-title").on("click",function(){
	$(".select-list").hide();
	$(this).siblings($(".select-list")).show();
	return false;
})
$(".select-list").on("click","li",function(){
	var txt = $(this).text();
	$(this).parent($(".select-list")).siblings($(".select-title")).find("span").text(txt);
})

// 分页器
$(".page-control").createPage({
	pageCount:{$data.total},  //总页数
	current:{$data.page},     //当前页数
	callbackFn:function(page){
		var index = layer.load(0, {shade: 0.1}); //0代表加载的风格，支持0-2
		var pageurl = '{$data.pageurl}';
		window.location.href=pageurl+"&page="+page; 
	}
});

$("tbody").find("tr:odd").css("backgroundColor","#eff6fa");

layui.use('upload', function(){
	var $ = layui.jquery
	,upload = layui.upload;
	upload.render({
		elem: '#test8'
		,url: "{:U('index/up')}"
		,accept: 'file'
		,auto: false
		//,multiple: true
		,bindAction: '#test9'
		,before: function(res){
			layer.load(3, {shade: 0.1}); //上传loading
		}
		,done: function(res){
			if(res.state=="fail"){
				layer.closeAll('loading');
				layer.msg('导入失败，'+res.message, {time: 5000, icon:5,shade: 0.7});
			}else{
				layer.closeAll('loading');
				layer.msg('导入成功！', {time: 5000, icon:6,shade: 0.7});
				window.location.reload();
			}
		},error: function(index, upload){
			layer.closeAll('loading');
		}
	});
});

$(document).ready(function(){
		var updatetime = 0;
		$(".isbn").each(function(i){
			var isbn = $(this).html();
			var bookname = $(this).attr("vi");
			if(isbn==''){
				return true;
			}
			if(bookname!=''){
				$("#myloading").html("");
				return true;
			}
			thisclass = "{$data['list'][0]['id']}";
			var url = "{:U('index/updateisbninfo')}&isbn="+isbn;
			$.getJSON(url,function(result){
				if(result.status==0){
					thisclass--;
					return false;
				}else{
					var imgstr = '<img src="'+result.image+'" width="50" style="padding:8px;">'+result.title;
					if(typeof(result.title)!="undefined"){
						$("."+thisclass).find("td.bookname").html(imgstr);
						$("."+thisclass).find("td.price").html(result.price);
					}else{
						$("."+thisclass).find("td.bookname").html("系统未获取到该书数据");
					}
					thisclass--;
				}
			});
			
		})
});

function delsure(kucunid){
	if(kucunid==""){
		layer.msg('参数错误！', {icon: 2});return;
	}
	layer.confirm('是否确认删除该信息？', {
		icon: 3,
		btn: ['确认','取消'] //按钮
	}, function(){
		var url = "{:U('index/delbook')}&kucunid="+kucunid;
		window.location.href=url;
	});
}


$("#printlist").click(function(){
	var url = "{:U('index/printlistsure')}";
	window.location.href=url;
})
</script>
</html>
